#include "dlist.h"
#include <stdio.h>

int main(void)
{
	struct bus circuit[] = {
				{1,"北站","南站",555},
				{2,"东站","西站",666},
				{3,"左站","右站",777}
				};
	int n = sizeof circuit / sizeof circuit[0];
	FILE* fp;
	if(!(fp = fopen("bus.dat","w+")))
	{
		puts("文件打开失败!");
		return -1;
	}
	fwrite(circuit, sizeof(struct bus), n, fp);
	NODE* head;
	fseek(fp, 0, 0);
	struct bus p[3];
	fread(p, sizeof(struct bus), n, fp);
	register int i = 0;
	for(; i < n; i++)
	{
		if(-1 == dlist_add(&head,p[i]))
			break;
	}
	dlist_print(head);
	dlist_free(&head);
	fclose(fp);
}
